//
// C++ Interface: model
//
// Description: 
//
//
// Author: Os3 s.r.l. <xgui@os3.it>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//

%ignore xgui::TreeNode;

namespace xgui
{
	class View;
	class Master;
    %feature("docstring","derives from :class:`xgui.ObjectClass` ") ModelClass;
	struct ModelClass : public xgui::ObjectClass
	{
		ModelClass();
		std::string const &className();
		bool isInstanceable();
		bool isModel();
		bool mustFinalize();
		xgui::Object * create(xgui::Object * parent, xgui::StringMap &properties);
		void finalize(xgui::Object * o);

		virtual bool canContain(xgui::ClassInfo * c);
		virtual bool canBeContainedIn(xgui::ClassInfo * c);
	};
    
    %feature("docstring","**DESCRIPTION**\n\nThe TreeNode class is used to implement a tree and represents a single node that can have one or more children nodes. This class is used as a base class of the :class:`xgui::Model` class.\n\n**PROPERTIES**\n\n* **style** *(RW):* sets or retrieves the visual style to be used by style-managed views when displaying this model element.\n\n **METHODS**\n\n") TreeNode;
	class TreeNode : public xgui::Object
	{
		public:
			typedef std::vector<TreeNode *>::iterator iterator;
	
			TreeNode ();
			virtual ~TreeNode ();

	        %feature("docstring","adds the specified tree node as a child of this node. The child is added to the tail of the child list.\n\n*C++*::\n\n void appendChild ( TreeNode * child );\n\n") appendChild ;
			virtual void appendChild ( TreeNode * child );
			%feature("docstring","inserts the specified tree node as a child of this node. The child is added at the specified position of the child list.\n\n*C++*::\n\n void insertChild ( TreeNode * child, int pos );\n\n") insertChild;
			virtual void insertChild ( TreeNode * child, int pos );
			%feature("docstring","removes the child at the specified position of the child list.\n\n*C++*::\n\n void removeChild ( int pos );\n\n") removeChild;
			virtual void removeChild ( int pos );
			%feature("docstring","removes all the children of the tree node\n\n*C++*::\n\n void removeAllChildren();\n\n") removeAllChildren;
			virtual void removeAllChildren();

            %feature("docstring","returns the number of children of this tree node\n\n*C++*::\n\n unsigned int size();\n\n") size;
			unsigned int size();
			%feature("docstring","returns a string that describes the id of this node and of all its parent nodes. The format is the follwing:\n\"<root_node_id>[/<parent_node_id>[...]]/<node_id>\"\n\n*C++*::\n\n std::string path();\n\n") path;
			std::string path();

	        %feature("docstring"," returns a reference to the child at the specified position in the child list.\n\n*C++*::\n\n TreeNode * getChild ( int pos );\n\n") getChild;
			TreeNode * getChild ( int pos );
			%feature("docstring","substitutes the child at the specified position in the child list with <new_child>.\n\n*C++*::\n\n void setChild ( TreeNode * new_child, int pos );\n\n") setChild;
			virtual void setChild ( TreeNode * new_child, int pos );
			%feature("docstring","returns a child giving its path.\n\n*C++*::\n\n xgui::TreeNode * findByPath(std::string const &path);\n\n") findByPath;
			xgui::TreeNode * findByPath(std::string const &path);
			%feature("docstring","returns the parent node of the tree node.\n\n*C++*::\n\n TreeNode * getParent();\n\n") getParent;
			TreeNode * getParent();
	
	        %feature("docstring","returns an iterator object referring to the first child of this node.\n\n*C++*::\n\n iterator begin ();\n\n") begin;
			iterator begin ();
			%feature("docstring","returns an iterator object referring to the last child of this node.\n\n*C++*::\n\n iterator end();\n\n") end;
			iterator end();
	
	        %feature("docstring","increments the reference counter of this node.\n\n*C++*::\n\n void ref();\n\n") ref;
			void ref();
			%feature("docstring","decrements the reference counter of this node, and destroyes the node if it reaches 0.\n\n*C++*::\n\n void unref();\n\n") unref;
			void unref();
	};

    %feature("docstring","**DESCRIPTION**\n\nThe Model class is used as a repository for the data shown in views. Views are widgets derived from the View class and to them a Model is assigned. The same Model can be assigned to different views so the same data can be displayed in different widgets. Each Model object is a node of a tree and so can contain one or more children. The data associated with a model node is represented by a list of strings. This class cannot be directly instantiated but it must be create using the :meth:`xgui.Master.CreateModel()` function.\n\n**METHODS**") Model;
	class Model : public TreeNode
	{
		protected:
			Model();
			virtual ~Model();

		public:
		    %feature("docstring","adds a new child to the end of the child list of this model node. The child could be filled with the specified vector of strings or with just one string. <style_name> specifies the name of a style to be used by views when displaying this item. The style is defined in the StyleManager object. NOTE: this method cannot be dynamically called. Called with param <child> adds the specified child to the end of the child list of this model node\n\n*C++*::\n\n void appendChild ( std::vector<std::string> const & string_list, std::string const &style_name = \"default\" );\n\n \
void appendChild ( std::string const & val, std::string const &style_name = \"default\" );\n\n \
void appendChild ( TreeNode * child );\n\n") appendChild;
			void appendChild ( std::vector<std::string> const & string_list, std::string const &style_name = "default" );
			void appendChild ( std::string const & val, std::string const &style_name = "default" );
			void appendChild ( TreeNode * child );

            %feature("docstring","inserts the specified child at the specified position of the child list of this model node.\n\n*C++*::\n\n void insertChild ( TreeNode * child, int pos );\n\n") insertChild;
			void insertChild ( TreeNode * child, int pos );
			%feature("docstring","removes the child at the specified position of the child list.\n\n*C++*::\n\n void removeChild ( int pos );\n\n") removeChild ;
			void removeChild ( int pos );
			%feature("docstring","removes all the children of the model\n\n*C++*::\n\n void removeAllChildren ();\n\n") removeAllChildren;
			void removeAllChildren ();
			%feature("docstring","substitutes the child at the specified position of the child list with <new_child>\n\n*C++*::\n\n void setChild ( TreeNode * new_child, int pos );\n\n") setChild;
			void setChild ( TreeNode * new_child, int pos );
			%feature("docstring","returns the child at the specified position of the child list.\n\n*C++*::\n\n xgui::Model * getChild( int pos );\n\n") getChild;
			xgui::Model * getChild( int pos );
			%feature("docstring","returns a child giving its path (see TreeNode::path())\n\n*C++*::\n\n xgui::Model * findByPath( std::string const &path );\n\n") findByPath;
			xgui::Model * findByPath( std::string const &path );

            %feature("docstring","set a flag for this model node. <flag> is a bit mask specifying the bits that are to be set.\n\n*C++*::\n\n void setFlag(unsigned long flag);\n\n") setFlag;
			void setFlag(unsigned long flag);
			%feature("docstring","unset a flag for this model node. <flag> is a bit mask specifying the bits that are to be unset.\n\n*C++*::\n\n void unsetFlag(unsigned long flag);\n\n") unsetFlag;
			void unsetFlag(unsigned long flag);
			%feature("docstring","returns true if the specified flags are set. <flag> is a bit mask specifying the bits that are to be checked.\n\n*C++*::\n\n bool getFlagStatus(unsigned long flag);\n\n") getFlagStatus;
			bool getFlagStatus(unsigned long flag);

            %feature("docstring","sets the visual style to be used by style-managed views when displaying this model element.\n\n*C++*::\n\n void setStyle ( std::string const & style_name );\n\n") setStyle;
			void setStyle ( std::string const & style_name );
			%feature("docstring","returns the name of the style assigned to this model element.\n\n*C++*::\n\n std::string const & getStyle();\n\n") getStyle;
			std::string const & getStyle();

            %feature("docstring","adds a string to the string list of this model element\n\n*C++*::\n\n void addString(std::string const &str);\n\n") addString;
			void addString(std::string const &str);
			%feature("docstring","removes the string at the specified position of the string list of this model element\n\n*C++*::\n\n void delString(int pos);\n\n") delString;
			void delString(int pos);
			%feature("docstring","substitutes the string at the specified position of the string list of this model element with <str>\n\n*C++*::\n\n void setString(std::string const &str, int pos);\n\n") serString;
			void setString(std::string const &str, int pos);
			%feature("docstring","returns the string of the specified position of the string list of this model element.\n\n*C++*::\n\n const std::string & getString ( int pos );\n\n") getString;
			const std::string & getString ( int pos );
			%feature("docstring","removes all strings of this model element.\n\n*C++*::\n\n void clearStrings();\n\n") clearStrings;
			void clearStrings();
			%feature("docstring","returns the string list's lenght of this model element.\n\n*C++*::\n\n unsigned int numberOfStrings();\n\n") numberOfStrings();
			unsigned int numberOfStrings();

            %feature("docstring","refreshes all the views associated with this model (calling the refresh() method on each view).\n\n*C++*::\n\n void updateViews();\n\n") updateViews;
			void updateViews();
             %feature("docstring","return the number of model's childen.\n\n*C++*::\n\n unsigned int size();\n\n") size;
			unsigned int size();
	};
}
